<?php 
$this->headScript()->appendFile($this->publicUrl . "Scripts/jquery.js");
$this->headScript()->appendFile($this->publicUrl . "Scripts/jquery.autocomplete.js");
$this->headScript()->appendFile($this->publicUrl . "Scripts/lib/jquery.bgiframe.js");
$this->headScript()->appendFile($this->publicUrl . "Scripts/jquery.hotkeys.js");
$this->headLink()->appendStylesheet( $this->publicUrl . 'autocomplete.css'); 
?>

<?php $this->headScript()->captureStart(); ?>
	$(document).ready(function(){
	
		var data = [ 
		<?php
		$query = new Doctrine_Query();
		$query->from('Db_Shop_Record_User');
		$first = true; 
		foreach($query->fetchArray() as $user) { ?>
			<?php if ( !$first ) {echo ",";} $first = false ?>			
			'<?= $user['username'] ?>'
		<?php } ?>
		];
		
		$("#username").autocomplete(data, {minChars: 0, mustMatch: false, matchContains: false}).
			result(function(x)
				{
					$("#password").val($("#username").val());
				});
		//$("#username").result().next().click( function() { $("#password").val('lama'); } );
	});
<?php $this->headScript()->captureEnd() ?>